﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.RoleCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.RoleCommandHandler
{
    public class GetRolesCommandHandler : IRequestHandler<GetRolesCommand, Results<PageOutput<Role>>>
    {
        private readonly IRoleService roleService;

        public GetRolesCommandHandler(IRoleService roleService)
        {
            this.roleService = roleService;
        }
        public async Task<Results<PageOutput<Role>>> Handle(GetRolesCommand request, CancellationToken cancellationToken)
        {
            var list = await roleService.GetRoles(request.Input);
            return Results<PageOutput<Role>>.DataResult(list);
        }
    }
}
